/************************************************************************
 * @file LoggerService.h
 * @author Ian Chen
 * @version 1.0
 * 
 * @section LICENSE
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 * General Public License for more details at
 * http://www.gnu.org/licenses/lgpl.html
 ************************************************************************/
#ifndef LOGGER_SERVICE_H
#define LOGGER_SERVICE_H

#include <memory>
#include <plugin/service/AbstractService.h>

namespace antu
{
namespace plugin
{

class AbstractLogCommand;

//!
/*!
*/
class PLUGINSHARED_EXPORT LoggerService : public AbstractService
{
private:
    shared_ptr<AbstractLogCommand> m_pLogCommand;

    QString m_sLogLevel;

public:
    //!
    /*!
    */
    enum LogType
    {
        LVL_DEBUG,
        LVL_INFO,
        LVL_WARNING,
        LVL_ERROR,
        LVL_FATAL
    };

    const static char* LOG_COMMAND_NAME;
    const static char* LOG_PARAM_TYPE;
    const static char* LOG_PARAM_CLASS;
    const static char* LOG_PARAM_METHOD;
    const static char* LOG_PARAM_MESSAGE;
    const static char* LOG_PARAM_FILE;
    const static char* LOG_PARAM_LINE;
    const static char* LOG_LEVEL_DEBUG;
    const static char* LOG_LEVEL_INFO;
    const static char* LOG_LEVEL_ERROR;
    const static char* LOG_LEVEL_WARN;
    const static char* LOG_LEVEL_FATAL;
    const static char* LOGGER_SERVICE;

    //!
    /*!
    */
    LoggerService(const QString& level = QString("debug"));

    //!
    /*!
    */
    void log(LogType type, const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void debug(const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void info(const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void warn(const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void error(const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void fatal(const QString& fileName, int line, const QString& className, const QString& methodName, const QString& message);

    //!
    /*!
    */
    void setLogLevel(const QString& logLevel);

    void setLogLevel(LoggerService::LogType level);

    QString logLevel();

    void setLogCommand(AbstractLogCommand* pCommand);
};

typedef shared_ptr<LoggerService> LoggerServiceSharedPtr;
}
}

#endif
